package pacBiopackage;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class PacBioKmerCheck {
	
	private HashMap<Integer, Integer> distanceDistribution = null;
	
	public PacBioKmerCheck() 
	{
		
	}
	
	
	public void init()
	{
		this.distanceDistribution = new HashMap<Integer, Integer>();
	}
	
	public List<Integer> checkForKmer(PacBioReadContainer read)
	{
		List<Integer> validKmers = new ArrayList<Integer>();
		if(!read.getPositionsList().isEmpty())
		{
			List<Integer>positionRef = read.getPositionsList();
			int tempSave = positionRef.get(0);
			for(int i=1; i < positionRef.size();++i)
			{
				int distance = positionRef.get(i)-tempSave;
				if(this.distanceDistribution != null)
				{
					if(this.distanceDistribution.containsKey(distance))
					{
	//					int bla = this.distanceDistribution.get(distance);
						this.distanceDistribution.put(distance,this.distanceDistribution.get(distance)+1);
					}
					else
					{
						this.distanceDistribution.put(distance,1);
					}
				}
				if(distance>50)
				{
					validKmers.add(i);
				}
				tempSave=positionRef.get(i);
			}
			return validKmers;
		}
		else
			return validKmers;
	}
	
	public HashMap<Integer, Integer>getDistanceDistribution()
	{
		return this.distanceDistribution;
	}

}
